<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3-6 Vue中的样式绑定</title>
    <script src="../vue.js"></script>
    <style>
        .activated {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <div :style="styleObj" @click="handleDivClick">
            yu kai
        </div>

        <div :style="[styleObj,{fontSize:'30px'}]" @click="handleDivClick">
            hello world
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                styleObj: {
                    color: "red"
                }
            },
            methods: {
                handleDivClick() {
                    this.styleObj.color = this.styleObj.color === "black" ? "red" : "black";
                }
            },
        })
    </script>
</body>

</html>